package com.xvxingan.mvc.mq.service;

import java.util.Map;

import javax.annotation.PostConstruct;

import org.apache.camel.CamelContext;
import org.apache.camel.Consume;
import org.apache.camel.Headers;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


public class MqService {
/*	@Autowired
	private CamelContext camelContext;
	@Produce(uri="jms:Vt.queue1")
	public  ProducerTemplate producer;
	@Produce(uri="jms:queue:Vt.queue1")
	public  ProducerTemplate qproducer;
	@Produce(uri="jms:topic:Vt.queue1")
	public  ProducerTemplate tproducer;
	@Produce(uri="jms:topic:queue1")
	public  ProducerTemplate tproducer2;
	Logger logger = Logger.getLogger(this.getClass());
	@PostConstruct
	public void init(){
		try {
			this.camelContext.addRoutes(new RouteBuilder(){

				@Override
				public void configure() throws Exception {
					this.from("jms:Vt.queue1").to("bean:mqService?method=handle").routeId("service1");;
					this.from("jms:queue:Vt.queue1").to("bean:mqService?method=handleQueue").routeId("service12");;
					this.from("jms:topic:Vt.queue1").to("bean:mqService?method=handleTopic").routeId("service11");;
					
				}});
		} catch (Exception e) {
  			logger.error(e);
		}
	}
	public void handle(@Headers() Map<String,String> map){
		System.out.println("1" + map.toString());
	}
	public void handleQueue(@Headers() Map<String,String> map){
		System.out.println("1q" + map.toString());
	}
	public void handleTopic(@Headers() Map<String,String> map){
		System.out.println("1t" + map.toString());
	}
	@Consume(uri="jms:Vt.queue1")
	public void handleC11(@Headers() Map<String,String> map){
		System.out.println("11" + map.toString());
	}
	@Consume(uri="jms:queue:Vt.queue1")
	public void handleC12(@Headers() Map<String,String> map){
		System.out.println("11q" + map.toString());
	}
	@Consume(uri="jms:topic:Vt.queue1")
	public void handleC13(@Headers() Map<String,String> map){
		System.out.println("11c" + map.toString());
	}*/
}
